package cn.yrec.rain.analysis.controller;

import cn.yrec.rain.analysis.domain.ResponseData;
import cn.yrec.rain.analysis.model.vo.HystResult;
import cn.yrec.rain.analysis.service.HydDataService;
import cn.yrec.rain.analysis.vo.HydDataRequestParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 描述:
 * 提供对流域水文站数据的查询服务
 *
 * @createDate: 2023/05/30 17:21
 * @author: yanglichen
 */
@RestController
@RequestMapping("/hyd")
public class HydDataAnalyseController {

    @Autowired
    private HydDataService hydDataService;


    /**
     * 方法描述: 通过流域名称和时间范围得到流域范围关键水文站的流量过程
     *
     * @return 关键水文站流量过程
     * @author yanglichen
     * @date 2023-05-30 17:24
     **/
    @PostMapping("/getByBasinNameListAndTime")
    public ResponseData getByBasinNameListAndTime(@RequestBody HydDataRequestParam param) {
        List<HystResult> result = hydDataService.getByBasinNameListAndTime(param);
        if (result == null || result.size()==0) {
            return ResponseData.fail("当前所选流域范围内没有对应的水文站信息", 500);
        }
        return ResponseData.ok(result);
    }
}
